#include<sys/types.h>
#include<sys/wait.h>
#include<unistd.h>
#include<stdlib.h>
#include<stdio.h>
void Printf()
{
    int cnt=5;
    while(cnt--)
    {
        printf("i am child process\n");
        sleep(1);
    }
}
int main()
{
    pid_t id=fork();
    if(id<0) exit(1);
    else if(id==0)
    {
        Printf();
        exit(1);
    }
    int status=0;
    pid_t wid=wait(&status);
    printf("wait success,pid:%d,exit code:%d,sig code:%d\n",wid,(status>>8)&0xff,status&0x7f);
    return 0;
}
